//
//  TSMineHomeViewController.m
//  AppCommonUICollect
//
//  Created by ciyouzen on 2017/2/25.
//  Copyright © 2017年 dvlproad. All rights reserved.
//

#import "TSMineHomeViewController.h"
#import "TSWebAddToDiffViewController.h"


@interface TSMineHomeViewController () {
    
}
@property (nonatomic, strong) NSString *userId;

@end

@implementation TSMineHomeViewController

- (instancetype)initWithUserId:(NSString *)userId {
    self = [super initWithNibName:nil bundle:nil];
    if (self) {
        self.userId = userId;
    }
    return self;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.navigationItem.title = [NSString stringWithFormat:@"用户id_%@", self.userId];
    
    NSMutableArray *sectionDataModels = [[NSMutableArray alloc] init];
    
    {
        CJSectionDataModel *sectionDataModel = [[CJSectionDataModel alloc] init];
        sectionDataModel.theme = @"个人中心";
        {
            CJModuleModel *module = [[CJModuleModel alloc] init];
            module.title = @"返回小程序";
            module.actionBlock = ^{
                [self.navigationController popViewControllerAnimated:YES];
            };
            [sectionDataModel.values addObject:module];
        }
        {
            NSString *title = @"游戏";
            NSUInteger randomNumber = arc4random_uniform(1000);
            NSString *randomString = [NSString stringWithFormat:@"%03lu", (unsigned long)randomNumber];
            NSDictionary *urlParams = @{@"title": title, @"userId": @"1001", @"randomNum": randomString};
            NSString *mpString = [NSString stringWithFormat:@"%@_%@", title, randomString];
            CJModuleModel *module = [[CJModuleModel alloc] init];
            module.title = [NSString stringWithFormat:@"进入小程序:%@", mpString];
            module.actionBlock = ^{
                TSWebAddToDiffViewController *viewController = [[TSWebAddToDiffViewController alloc] initWithUrlParams:urlParams];
                viewController.hidesBottomBarWhenPushed = YES;
                [self.navigationController pushViewController:viewController animated:YES];
            };
            [sectionDataModel.values addObject:module];
        }
        [sectionDataModels addObject:sectionDataModel];
    }
    
    self.sectionDataModels = sectionDataModels;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
 #pragma mark - Navigation
 
 // In a storyboard-based application, you will often want to do a little preparation before navigation
 - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
 // Get the new view controller using [segue destinationViewController].
 // Pass the selected object to the new view controller.
 }
 */

@end
